package com.tsingteng.cosfun.utils;

import com.tsingteng.cosfun.helper.VideoHelper;



public class VideoOrderCommand extends Command {

    public int formIndex;
    public int toIndex;


    public VideoOrderCommand(int formIndex, int toIndex) {
        this.formIndex = formIndex;
        this.toIndex = toIndex;
    }

    @Override
    public boolean apply() {
        String formPath = VideoHelper.getIntence().getVideoPathByIndex(formIndex);
        long formTime = VideoHelper.getIntence().getVideoTimeByIndex(formIndex);
        boolean removeVideoInfo = VideoHelper.getIntence().removeVideoInfo(formIndex);
        boolean addVideoInfo = VideoHelper.getIntence().addVideoInfo(formPath, formTime, toIndex);
        VideoHelper.getIntence().initVideoSelectBean();
        if (addVideoInfo && removeVideoInfo) {
            return true;
        }
        return false;
    }

    @Override
    public boolean unapply() {
        String toPath = VideoHelper.getIntence().getVideoPathByIndex(toIndex);
        long toTime = VideoHelper.getIntence().getVideoTimeByIndex(toIndex);
        boolean removeVideoInfo = VideoHelper.getIntence().removeVideoInfo(toIndex);
        boolean addVideoInfo = VideoHelper.getIntence().addVideoInfo(toPath, toTime, formIndex);
        VideoHelper.getIntence().initVideoSelectBean();
        if (addVideoInfo && removeVideoInfo) {
            return true;
        }
        return false;
    }
}
